//
// Description: 1221. 分割平衡字符串
// Created by Loading on 2021/9/7.
//

#include <bits/stdc++.h>

using namespace std;

int balancedStringSplit(string s) {
    int sum = 0, res = 0;
    for (auto &c : s) {
        if (c == 'L') {
            ++sum;
        } else {
            --sum;
        }
        // 平衡
        if (sum == 0) {
            ++res;
        }
    }

    return res;
}

int main() {
    string s = "LRRLLRRL";
    int res = balancedStringSplit(s);
    cout << res << endl;

    return 0;
}